package com.herench.bunch.lab.agent.impl;

import com.herench.bunch.lab.agent.LabOperationAgent;
import com.herench.bunch.lab.dao.LabOperationDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author luoxiaoming on 18-10-16 上午9:59
 * @email luoxiaoming@herench.com
 */


@Component
public class LabOperationAgentImpl implements LabOperationAgent {

    @Autowired
    private LabOperationDao labOperationDao;

    @Override
    public void modify(Map<String, Object> params) {
        labOperationDao.modify(params);
    }

    @Override
    public Map<String,Object> bill(Map<String, Object> params) {
        params.put("examType","");
        params.put("examDevice","");
        params.put("examDateTime","");
        params.put("inStatus","");
        params.put("reporter","");
        params.put("reportDateTime","");
        params.put("scheduledDateTime","");
        params.put("cancelReason","");

        labOperationDao.bill(params);
        System.out.print(params);
        return params;
    }

    @Override
    public Map<String, Object> labResultReport(List<Map<String, Object>> reportList) {
        Assert.isTrue(reportList!=null && !reportList.isEmpty(),"返回报告数据为空.");
        Map<String, Object> res = new HashMap<>();
        for (Map<String, Object> el : reportList) {
            labOperationDao.labResultReport(el);
            if (!"0".equals(el.get("ret"))){
                res.put("ret","-1");
                res.put("message","写入数据异常");
            }
        }
        res.put("ret","0");
        res.put("message","写入数据成功.");
       return res;
    }
}
